package com.example.dessert.util;

import com.alibaba.fastjson.JSONObject;


/**
 * @ClassName: ResultJson
 * @Description: 使用该类需要响应头加入json 例如：@RequestMapping(value = { "URL" }, method = { RequestMethod.POST }, produces="application/json;charset=UTF-8")
 * @Author
 * @Date 2021/12/31
 * @Version 1.0
 */
public class ResultJson {

    public static String success(String data) {

        JSONObject object = new JSONObject();
        object.put("code", ResultCode.SUCCESS_CODE);
        object.put("message", "成功");
        object.put("data", data);
        return object.toJSONString();

    }

    public static String error(Integer code, String message) {

        JSONObject object = new JSONObject();
        object.put("code", code);
        object.put("codes", code);
        object.put("message", message);
        return object.toJSONString();

    }
}
